﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AllInOne
{
    interface IConsole
    {
        //void WriteLine(ConsoleColor color = ConsoleColor.White, string content = null);

        void WriteLine(ConsoleColor color = ConsoleColor.White, string format = null, params object[] args);

        void WriteLine(string format = null, params object[] args);

        string ReadLine();

        void Clear();

        void Write(string content);
    }

    class ConsoleUI : IConsole
    {
        public void Clear() { Console.Clear(); }

        public void WriteLine(ConsoleColor color = ConsoleColor.White, string content = null, params object[] args)
        {
            bool useColor = color != ConsoleColor.White;
            if (useColor) Console.ForegroundColor = color;

            if (content == null) Console.WriteLine();
            else if(args.Length < 1)
                Console.WriteLine(content);
            else Console.WriteLine(content, args);

            if(useColor) Console.ResetColor();
        }

        public void WriteLine(string format = null, params object[] args)
        {
            this.WriteLine(ConsoleColor.White, format, args);
        }

        public string ReadLine()
        {
           return Console.ReadLine();
        }

        public void Write(string content)
        {
            Console.Write(content);
        }
    }
}
